package com.hj.mp.demo.common;

import lombok.Data;

/**
 * 2020/4/1
 */
@Data
public class RestfulResponse<T> {

    /**
     * 状态码
     */
    private Integer stateCode = 200;

    /**
     * 自定义消息
     */
    private String message = "success";

    /**
     * 结果集
     */
    private T result;


    public RestfulResponse(Integer stateCode, T result) {
        this.stateCode = stateCode;
        this.result = result;
    }

    public RestfulResponse(Integer stateCode, String message) {
        this.stateCode = stateCode;
        this.message = message;
    }

    public RestfulResponse(Integer stateCode, String message, T result) {
        this.stateCode = stateCode;
        this.message = message;
        this.result = result;
    }

    public RestfulResponse(T result) {
        this.result = result;
    }

    public RestfulResponse() {
    }

    public static RestfulResponse build() {
        return new RestfulResponse();
    }

    public static <T> RestfulResponse build(T result) {
        return new RestfulResponse(result);
    }

    public static <T> RestfulResponse build(Integer stateCode, T result) {
        return new RestfulResponse(stateCode, result);
    }

    public static RestfulResponse build(Integer stateCode, String message) {
        return new RestfulResponse(stateCode, message);
    }

    public static <T> RestfulResponse build(Integer stateCode, String message, T result) {
        return new RestfulResponse(stateCode, message, result);
    }

}
